<%@ page import="com.ssm.pojo.Manager" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员界面</title>
    <link rel="stylesheet" href="static/css4/bootstrap.min.css">
    <script src="static/jq/jquery.js"></script>
    <script src="static/js4/bootstrap.min.js"></script>
    <style type="text/css">
        html body {
            height: 100%;
            margin: 0;
        }

        .header-logo {
            height: 15%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .bg-content {
            min-height: 100%;
        }

        .bg- {
            background-color: #6495ED;
        }

    </style>

    <script>
    </script>
</head>
<body>

<div class="bg-content">
    <div class="header-logo">
        <h1>欢迎来到管理员页面</h1>
    </div>
    <nav class="navbar navbar-expand-sm bg- navbar-dark">
        <div class="container">
            <ul class="navbar-nav">
                <li class="nav-item"><a href="${pageContext.request.contextPath}/toManagerIndex"
                                        class="nav-link link-light px-2">主页</a></li>
                <li class="nav-item"><a href="${pageContext.request.contextPath}/toStuShow"
                                        class="nav-link link-light px-2">学生信息</a></li>
                <li class="nav-item"><a href="${pageContext.request.contextPath}/toStuMistakeShow"
                                        class="nav-link link-light px-2">学生考勤信息</a></li>
                <li class="nav-item"><a href="${pageContext.request.contextPath}/toStushow"
                                        class="nav-link link-light px-2">学生考勤操作</a></li>
                <li class="nav-item"><a id="toUpload" href="#"
                                        class="nav-link link-light px-2">数据上传下载</a></li>
                <li class="nav-item"><a href="${pageContext.request.contextPath}/toUpdate"
                                        class="nav-link link-light px-2 active">修改个人信息</a></li>
                <li class="nav-item"><a href="${pageContext.request.contextPath}/toUpdate_pw"
                                        class="nav-link link-light px-2">修改密码</a></li>
                <li class="nav-item"><a href="#" class="nav-link link-light px-2">About</a></li>
            </ul>
            <ul class="navbar-nav justify-content-end">
                <li class="nav-item"><a href="#" class="nav-link link-light px-2"></a></li>
                <li class="nav-item">
                    <text class="nav-link link-light px-2" style="color:#000;"><b>你好，${manager.name}</b>
                    </text>
                </li>
                <li class="nav-item"><a href="${pageContext.request.contextPath}/logout"
                                        class="nav-link link-light px-2">退出</a></li>
            </ul>
        </div>
    </nav>
    <div class="container">
        <form>
            <div>
                <div class="form-group row">
                    <div class="col-sm-10">
                        <input type="hidden" readonly class="form-control-plaintext" name="num" value="${manager.num}">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">账号</label>
                    <div class="col-sm-10">
                        <input type="text" readonly class="form-control-plaintext" name="amount"
                               value="${manager.amount}">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">姓名</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="name" value="${manager.name}">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">性别</label>
                    <div class="col-sm-10">
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="sex" class="form-control" id="sex_input"
                                   value="1">
                            <label class="form-check-label">男</label>
                        </div>
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="sex" class="form-control" id="sex_input1"
                                   value="2">
                            <label class="form-check-label">女</label>
                        </div>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">年龄</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="age" value="${manager.age}">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">身份证</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="id" value="${manager.id}">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">电话</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="phone" value="${manager.phone}">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">地址</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="address" value="${manager.address}">
                    </div>
                </div>
                <div class="form-group row" style="display: flex;justify-content: center">
                    <button type="button" class="btn btn-success" id="save_btn">确定</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div style="background-color:#fff; height:20px;margin-bottom:0px"></div>
<footer class="footer" style="background-color:#F6F7F8; height:60px;margin-bottom:0px">
    <div class="container text-center">
        <p style="text-align: center;color: #777">
            copy© 2022-2022 舒崇 版权所有
            <br><br>
        </p>
    </div>
    <div id="gotop" style="display: block;"><a class="gotop" draggable="false"></a></div>
</footer>
<script type="text/javascript">
    $("#toUpload").click(function () {
        var amount = "${manager.amount}";
        $.ajax({
            url:"${pageContext.request.contextPath}/getAuthorAmount",
            type:"POST",
            data:"amount="+amount,
            success:function(result){
                if(result.code==100){
                    console.log(result.extend.author);
                    if(result.extend.author[0].statu!=2){
                        alert("权限不足！");
                        return;
                    }else{
                        window.location.href="${pageContext.request.contextPath}/toUpload";
                    }
                }else if(result.code==200){
                    alert("权限不足！")
                }
            }
        });
    });
    var manager_sex = "${manager.sex}";
    if (manager_sex == 1) {
        $("#sex_input").prop("checked", true);
    } else if (manager_sex == 2) {
        $("#sex_input1").prop("checked", true);
    }
    $("#save_btn").click(function () {
        alert($("form").serialize());
        $.ajax({
            url: "${pageContext.request.contextPath}/update",
            data: $("form").serialize(),
            type: "POST",
            success: function (result) {
                if(result.code==100){
                    alert("修改成功！")
                    window.top.location.href = window.location.href;
                }else if(result.code==200){
                    alert("修改失败！")
                }
            }
        });
    });


</script>
</body>
</html>
